package server;

import java.awt.BorderLayout;
import javax.swing.*;

public class MyJFrame extends JFrame {
	private static final long serialVersionUID = 1L;
	private JTextArea textarea;
	private JButton action;
	
	public MyJFrame(Control control) {
		this.setTitle("RMI Server GUI");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setLayout(new BorderLayout());
		this.setBounds(0,0,700,600);
		
		action = new JButton("Start");
		action.addActionListener(control);
		this.add(new MyJPanel(), BorderLayout.NORTH);
		
		textarea = new JTextArea();
		textarea.setEditable(false);
		JScrollPane scrollPane = new JScrollPane(textarea);
		this.add(scrollPane, BorderLayout.CENTER);
		
		this.setVisible(true);
	}
	
	public void addToTextArea(String s) {
		textarea.append(s);
	}
	
	private class MyJPanel extends JPanel {
		private static final long serialVersionUID = 1L;

		public MyJPanel() {
			this.add(action);
		}
	}
	
	public void setActionText(String s) {
		action.setText(s);
	}
}